﻿using PortfolioApp.Web.IDataAdapters.Adapters;
using PortfolioApp.Web.IDataAdapters.Interfaces;
using PortfolioApp.DataModels;
using PortfolioApp.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace PortfolioApp.Web.Controllers
{
    public class ngProjectsController : ApiController
    {
        IPortfolioAppAdapter _adapter = new PortfolioAppAdapter();
        public IHttpActionResult GET()
        {
            //List<Project> projects = _adapter.GetAllProjects();
            //return Ok(projects);
            return Ok(_adapter.GetAllProjects());
        }
        public IHttpActionResult GET(int id)
        {
            //Project project = _adapter.GetProject(id);
            //return Ok(project);
            return Ok(_adapter.GetProject(id));
        }
        public IHttpActionResult POST(Project project)
        {
            //Project newProject = new Project();
            //newProject.SetProps(project);
            //newProject.Id = _adapter.AddProject(project);
            //return Ok(newProject);
            return Ok(_adapter.AddProject(project));
        }
        public IHttpActionResult PUT(Project project)
        {
            //project = _adapter.UpdateProject(project);
            //return Ok(project);
            return Ok(_adapter.UpdateProject(project));
        }
        public IHttpActionResult DELETE(int id)
        {
            _adapter.DeleteProject(id);
            return Ok();
        }
    }
}
